/**
 * 
 */
package com.yst.metho.web.application.projectversion.actions.folder;

import nextapp.echo2.app.Extent;
import nextapp.echo2.app.event.ActionEvent;

import com.yst.metho.web.application.SuiviProdApp;
import com.yst.metho.web.application.components.GenericEditWindow;
import com.yst.metho.web.application.components.listingview.ToolbarAction;
import com.yst.metho.web.application.projectversion.views.ProjectClassificationListModel;
import com.yst.metho.web.application.projectversion.views.ProjectFolderPane;
import com.yst.suivi.data.project.Project;
import com.yst.suivi.data.rights.Right;
import com.yst.suivi.status.StatusConstants;

/**
 * @author perso
 * 
 */
public class CreateFolderAction extends ToolbarAction
{
	private ProjectClassificationListModel mModel;

	private Project mProject;

	/**
	 * 
	 */
	private static final String CREATE_FOLDER_COMMAND = "CreateProjectFolder";

	public CreateFolderAction(ProjectClassificationListModel model, Project project)
	{
		super(Right.CREATE_FOLDER, "Create");
		mProject = project;
		mModel = model;
		setActionCommand(CREATE_FOLDER_COMMAND);
		addActionListener(this);
		if (StatusConstants.CLOSE == mProject.getStatus())
		{
			setEnabled(false);
		}
	}

	public void actionPerformed(ActionEvent e)
	{
		if (CREATE_FOLDER_COMMAND.equals(e.getActionCommand()))
		{
			ProjectFolderPane view = new ProjectFolderPane(mProject);
			GenericEditWindow window = new GenericEditWindow(view, "Classification", new PrjFolderBtn(mModel, view));
			window.setHeight(new Extent(200, Extent.PX));
			SuiviProdApp.getApp().getDefaultWindow().getContent().add(window);
		}
	}
}
